<?php
/**
 * GameModel
 * 
 * @author Admin
 * @version 
 */
require_once 'Zend/Db/Table/Abstract.php';
class Admin_Models_QuanHuyenModel extends Zend_Db_Table_Abstract
{
    /**
     * The default table name 
     */
    protected $_name = 'tbl_quanhuyen';
    protected $_primary = 'idq';

    
    function addQuanHuyen($data){
       $db = Zend_Db_Table_Abstract::getDefaultAdapter();
       
        $mySql = $db->insert($this->_name, $data); 
        return $mySql;
    }
    function editQuanHuyen($data, $id){
       $db = Zend_Db_Table_Abstract::getDefaultAdapter();
        $where = "idq='".$id."'";
        $mySql = $db->update($this->_name, $data, $where); 
        return $mySql;
    }
    function listQuanHuyen(){
        $db = Zend_Db_Table_Abstract::getDefaultAdapter();
        $mySql = $db->select()->from($this->_name)->order('idq DESC')  ;      
        $result = $db->fetchAll($mySql);
        return $result;
    }
    function loadQHbyid($id){
         $db = Zend_Db_Table_Abstract::getDefaultAdapter();
        $mySql = $db->select()->from($this->_name)->where('idq = '.$id);
       //echo $mySql;die;
        $result = $db->fetchRow($mySql);
        return $result;
    }

    function delQuanHuyen($id){
         $db = Zend_Db_Table_Abstract::getDefaultAdapter();
        try{
        $mySql = $db->delete($this->_name, ' idq ='.$id);
        }catch(Exception $e){
            echo $e;
        }
        return $mySql;
    }
    
}